#include "CCursor.h"
#include "CInputManager.h"
#include "Game.h"



CCursor::CCursor()
{

}


CCursor::~CCursor()
{

}


CCursor* CCursor::GetInstance()
{
	static CCursor cursor;
	return &cursor;
}


void CCursor::Update()
{
	D3DXMATRIX matScaling;
	D3DXMATRIX matTranslation;

	//D3DXMatrixIdentity(&matTranslation);

	m_nXPos = CInputManager::GetInstance()->MouseGetPosX();
	m_nYPos = CInputManager::GetInstance()->MouseGetPosY();

	D3DXMatrixScaling(&matScaling, (float)cursorTexture->m_Width, (float)cursorTexture->m_Height, 1.0f);
	D3DXMatrixTranslation(&matTranslation, float(cursorTexture->m_Width / 2.0f) + (float)m_nXPos, 768.0f - float(cursorTexture->m_Height / 2.0f) - (float)m_nYPos, 0.1f);

	cursorTexture->m_pSprite->matWorld = matScaling * matTranslation;

}


void CCursor::Render()
{
	CRender::GetInstance()->Render2D(cursorTexture->m_pSprite);
}


void  CCursor::Init()
{
	cursorTexture = CRender::GetInstance()->LoadTexture2DFromFile("Resource/Images/cur.png");

	if(cursorTexture == NULL)
	{
		MessageBox( NULL, "Cursor didn't load.", "Error", MB_OK );
	}
}


void  CCursor::ShutDown()
{

}